home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Networking / OTStreamLogViewer1.0b1 / LogEngine / LogEngine.h < prev    next >
Encoding:
Text File  |  1998-03-15  |  4.0 KB  |  116 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        LogEngine.h
  3.  
  4.     Contains:    The core code to talk to the STREAMS log module.
  5.  
  6.     Written by:    Quinn "The Eskimo!"
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.     You may incorporate this sample code into your applications without
  13.     restriction, though the sample code has been provided "AS IS" and the
  14.     responsibility for its operation is 100% yours.  However, what you are
  15.     not permitted to do is to redistribute the source as "DSC Sample Code"
  16.     after having made changes. If you're going to re-distribute the source,
  17.     we require that you make it clear in the source that the code was
  18.     descended from Apple Sample Code, but that you've made changes.
  19. */
  20.  
  21. /////////////////////////////////////////////////////////////////////
  22. // Pick up toolbox "Files.h", which is needed
  23. // to make OpenTptClient.h compile.
  24.  
  25. #import <Files.h>
  26.  
  27. /////////////////////////////////////////////////////////////////////
  28. // Pick up low-level OT APIs.
  29.  
  30. #import <OpenTptClient.h>
  31. #import <strlog.h>
  32.  
  33. /////////////////////////////////////////////////////////////////////
  34. // Core Data Structure
  35.  
  36. enum {
  37.     kMagicValue = 'Bing'
  38. };
  39.  
  40. struct LogEntry {
  41.     OTLink *fNext;
  42.     OSType fMagic;                // Must be kMagicValue
  43.     UInt32 fRefCount;
  44.     UInt32 fTextLength;
  45.     struct log_ctl fLogHeader;
  46.     // variable length text goes here
  47. };
  48. typedef struct LogEntry LogEntry, *LogEntryPtr;
  49.  
  50. extern pascal void RetainLogEntry(LogEntryPtr thisEntry);
  51.     // Increments the reference count for the log entry.
  52.     // Clients can call this function to hold on to log
  53.     // entries that are passed to them by ForEachNewLogEntry.
  54.     //
  55.     // Context: SystemTask /only/
  56.     
  57. extern pascal void ReleaseLogEntry(LogEntryPtr thisEntry);
  58.     // Decrements the reference count for the log entry,
  59.     // and frees the entry if count decrements to zero.
  60.     // Clients should eventually call this function to free
  61.     // any log entry they have retained.
  62.     //
  63.     // Context: SystemTask /only/
  64.  
  65. /////////////////////////////////////////////////////////////////////
  66.  
  67. extern pascal OSStatus StartLogging(Boolean logErrors,
  68.                                 UInt32 traceInfoCount, struct trace_ids traceInfo[]);
  69.     // Tells the module to start logging.  If logErrors is true,
  70.     // the log will contain all strlog messages that have the
  71.     // SL_ERROR bit in the flags when they are created.  If
  72.     // traceInfoCount is non-zero, then we're also logging
  73.     // traces.  traceInfo must point to an array of trace_ids
  74.     // that describe which traces we're interested in.  Each
  75.     // trace_id contains a field for module ID, for stream ID,
  76.     // and for level.  Each field specifies the value of that
  77.     // parameter we accept, or -1 to accept any value for that
  78.     // parameter.  For example, the mid field is the module ID
  79.     // whose traces we should accept, or -1 if you want to accept
  80.     // traces for all modules.
  81.     //
  82.     // Context: SystemTask /only/
  83.  
  84. extern pascal void StopLogging(void);
  85.     // Stops the logging process.  Call this if and only if
  86.     // StartLogging returns noErr.  After stopping logging
  87.     // you should call ForEachNewLogEntry to get any log
  88.     // entries that might have accumulated in the time
  89.     // between you making the StopLogging call and the time
  90.     // that logging actually stops.
  91.     //
  92.     // Context: SystemTask /only/
  93.  
  94. extern pascal Boolean LoggingActive(void);
  95.     // Returns whether logging is currently active.
  96.     //
  97.     // Context: SystemTask /only/
  98.  
  99. extern pascal UInt32 NumberOfDroppedLogEntries(void);
  100.     // Returns the number of log entries that have been
  101.     // dropped due to memory constaints.  This should
  102.     // always be zero.
  103.     //
  104.     // Context: SystemTask /only/
  105.  
  106. typedef pascal void (*ProcessLogEntryProcPtr)(LogEntryPtr logEntry, void *refCon);
  107.  
  108. extern pascal void ForEachNewLogEntry(ProcessLogEntryProcPtr doThis, void *refCon);
  109.     // This routine calls the supplied doThis routine for each
  110.     // log entry that has arrived since the last time you called
  111.     // this routine.  The log entry is immediately released
  112.     // after doThis returns, so you should call RetainLogEntry
  113.     // if you keep a reference to it.
  114.     //
  115.     // Context: SystemTask /only/
  116.